package org.syncsoft.overalt.gui.impl.window.commitFiles;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

import javax.swing.JLabel;
import javax.swing.JTable;

import org.syncsoft.overalt.common.api.Resource;
import org.syncsoft.overalt.gui.api.window.AbstractWindow;
import org.syncsoft.overalt.gui.impl.componentPlugin.TableStringComponentPlugin;
import org.syncsoft.overalt.gui.util.BuildFormWindow;

/**
 * 
 * @author tptfc
 *
 */
public class CommitFilesWindow extends AbstractWindow {
	private Collection<String> filePaths;
	
	{
		setFilePaths(new HashSet<String>());
	}
	
	public CommitFilesWindow(CommitFilesWindowController controller) {
		super(controller);
	}

	public CommitFilesWindow(int width, int height, CommitFilesWindowController controller) {
		super(width, height, controller);
	}

	@Override
	protected void buildWindow() {
		setTitle(Resource.getProperty("overalt.text.commit.files"));
		BuildFormWindow build = new BuildFormWindow(getPanel());
		
		JLabel label;
		
		Collection<String> columnsName = new ArrayList<String>();
		columnsName.add("");
		columnsName.add(Resource.getProperty("overalt.text.file.path"));
		JTable filePathTable = newTableString("filePaths", columnsName, getFilePaths());
		
		label = new JLabel(Resource.getProperty("overalt.label.files"));
		build.add(label, filePathTable);
		
		
		label = new JLabel(Resource.getProperty("overalt.text.versionDescription"));
		build.add(label, newTextArea("versionDescription"));
		
		addSaveAndCancelButtons(build);
	}
	
	/**
	 * 
	 * @param key
	 * @param columnsName
	 * @param values
	 * @return
	 */
	private JTable newTableString(String key, Collection<String> columnsName, Collection<String> values) {
		return getComponentPlugin(TableStringComponentPlugin.class).newTable(key, columnsName, values, values);
	}

	Collection<String> getFilePaths() {
		return filePaths;
	}
	void setFilePaths(Collection<String> filePaths) {
		this.filePaths = filePaths;
	}
}
